-content_for :modal_title do
  Select References

-content_for :modal_help, :select_references

%script#document_option{ :type => 'text/html', :'data-prefix' => 'document' }
  %li{ :'data-id' => '<%= document.id %>', :'data-title' => '<%= document.title %>', :'data-document_type' => '<%= document.document_type %>', :'data-link_url' => '<%= document.link_url %>' }
    .row-fluid
      .span10
        .object-info
          %span.name <%= document.title || document.link_url || '' %>
          %span.option <%= document.document_type || '' %>
      .span2.actions
        .pull-right
          %a.widgetbtn.btn.btn-mini{ :href => edit_flow_document_path('<%=document.id%>'), :'data-toggle' => 'modal-ajax-listeditform', :'data-selector-target' => '.source, .target', :'data-modal-class' => 'modal-wide' }
            %i.grcicon-edit
          %a.widgetbtn.btn.btn-mini{ :href => '#', :'data-toggle' => 'selector-list-select' }
            %i.grcicon-chevron-right

%script#document_option_data{ :type => 'text/html' }
  .object-info
    %span.name <%= document.title || document.link_url || '&nbsp;' %>
    %span.option <%= document.document_type || '&nbsp;' %>

%script#object_document_selected{ :type => 'text/html', :'data-mappings' => 'object:document', :'data-member' => 'object_document' }
  %li{ :'data-id' => '<%= id %>', :'data-object-id' => '<%= document.id %>' }
    .row-fluid
      .span6.object_info{ :'data-template-id' => 'document_option_data' }
      .span6.actions
        %span.state
        .pull-right
          %input{ :type => 'hidden', :name => 'items[<%= id %>][id]', :value => '<% if (id.toString().substr(0,3) != "new") { %><%= id %><% } %>'.html_safe }
          %input{ :type => 'hidden', :name => 'items[<%= id %>][documentable_type]', :value => object.class.name }
          %input{ :type => 'hidden', :name => 'items[<%= id %>][documentable_id]', :value => object.id }
          %input{ :type => 'hidden', :name => 'items[<%= id %>][document_id]', :value => '<%= document.id %>' }
          %input._destroy{ :type => 'hidden', :name => 'items[<%= id %>][_destroy]', :value => '' }
          %a.widgetbtn.btn.btn-mini{:href => edit_flow_document_path('<%=document.id%>'), :'data-toggle' => 'modal-ajax-listeditform', :'data-selector-target' => '.source, .target', :'data-modal-class' => 'modal-wide' }
            %i.grcicon-edit
          %a.widgetbtn.add-me.btn.btn-mini{:href => "#", :'data-toggle' => 'selector-list-remove'}
            %i.grcicon-remove

.row-fluid.modal-source
  .span6
    .row-fluid
      .span7
        %h3
          Add Reference
          %a.btn.btn-add{ :href => new_flow_document_path, :'data-toggle' => 'modal-ajax-listnewform', :'data-selector-target' => '.source, .target', :'data-modal-class' => 'modal-wide' }
            %i.grcicon-add
      .span5
        %input.widgetsearch.input-block-level{:type => "text", :placeholder => "Search References"}

    .filter-block
      .row-fluid
        .span12
          .tabbable.tabs-left
            .tab-content
              #category1.tab-pane.active
                .people-list
                  %ul.source{ :'data-list-data-href' => flow_documents_path(:format => :json), :'data-template-id' => 'document_option' }

  .span6
    %h3
      Associated References

    .people-list.currentlist
      %ul.target{ :'data-list-data-href' => flow_object_documents_path(:object_type => object.class.name, :object_id => object.id), :'data-template-id' => 'object_document_selected' }

